package com.cet.regularexpression;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @program: algorithm
 * @description: 时间格式匹配，获取时分秒
 * @author: 陈恩涛
 * @create: 2021-06-22 09:49
 **/
public class Main08 {

    private static Pattern TIME_PATTERN = Pattern.compile("([01]\\d|2[0-3]):([0-5]\\d):([0-5]\\d)");

    public static void main(String[] args) {
        Matcher m = TIME_PATTERN.matcher("23:01:59");
        if (m.matches()) {
            System.out.println(m.group(1));
            System.out.println(m.group(2));
            System.out.println(m.group(3));
        } else {
            System.out.println("匹配失败！");
        }
    }

}
